<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*,swimv2gm.bl.util.UserData"%>
<!DOCTYPE html>
<html>
<head>
<title>SWIMv2: Lista amici</title>
<link rel="stylesheet" type="text/css"
	href="/SWIMv2gm/shared/global.css" />
</head>
<body>
	<div id="header">
		<h1>SWIMv2</h1>
	</div>
	<%@include file="/shared/menu.jsp"%>
	<div id="content">
		<h1>Amici</h1>

		<h2>Confermati</h2>
		<%
			List<UserData> friends = ((List<UserData>)request.getAttribute("friends"));
			if (friends == null || friends.size() == 0) {
		%>
		<p class="list message">Nessun amico presente.</p>
		<%
			}
			else {
		%><table class="list">
			<%
				for (UserData u:friends) {
			%>
			<tr>
				<td><a href="Profile?uid=<%=u.getId()%>"><%=u.getNome()%> <%=u.getCognome()%></a></td>
				<td><a class="decline"
					href="RemoveFriend?friend=<%=u.getId()%>">Rimuovi</a></td>
			</tr>
			<%
				}
			%>
		</table>
		<%
			}
		%>

		<h2>Richieste in corso di approvazione</h2>

		<h3>Ricevute</h3>
		<%
			List<UserData> received = ((List<UserData>)request.getAttribute("received"));
			if (received == null || received.size() == 0) {
		%>
		<p class="list message">Nessuna richiesta presente.</p>
		<%
			}
			else {
		%><table class="list">
			<%
				for (UserData u:received) {
			%>


			<tr>
				<td><a href="Profile?uid=<%=u.getId()%>"><%=u.getNome()%> <%=u.getCognome()%></a></td>
				<td><a class="accept"
					href="ProcessFriendship?mitt=<%=u.getId()%>&accept=true">Accetta</a></td>
				<td><a class="decline"
					href="ProcessFriendship?mitt=<%=u.getId()%>&accept=false">Rifiuta</a></td>
			</tr>
			<%
				}
			%>
		</table>
		<%
			}
		%>

		<h3>Inviate</h3>
		<%
			List<UserData> sent = ((List<UserData>)request.getAttribute("sent"));
			if (sent == null || sent.size() == 0) {
		%>
		<p class="list message">Nessuna richiesta presente</p>
		<%
			}
			else {
		%><table class="list">
			<%
				for (UserData u:sent) {
			%>
			<tr>
				<td><a href="Profile?uid=<%=u.getId()%>"><%=u.getNome()%> <%=u.getCognome()%></a></td>
				<td><a class="decline"
					href="RemoveFriend?friend=<%=u.getId()%>">Rimuovi</a></td>
			</tr>
			<%
				}
			%>
		</table>
		<%
			}
		%>
	</div>
</body>
</html>